<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>添加节点</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <script type="text/javascript" src="js/cookie.js"></script>
    <script type="text/javascript" src="js/address.js"></script>
</head>

<body>
<script>
    $(function () {
        $("#add").click(function (){
            var id=$("#L_id").val();
            var nodeName=$("#L_nodeName").val();
            var nodeType=$("#L_nodeType").val();
            var regionCode=$("#L_regionCode").val();
            var telCode=$("#L_telCode").val();
            var x=$("#L_x").val();
            var y=$("#L_y").val();
            // console.log(JSON.stringify({"id":id,"nodeName":nodeName,"nodeType":nodeType,
            //     "regionCode":regionCode,"telCode":telCode,"x":x,"y":y}));
            $.ajax({
                url: address+"transNode/add",
                type: "post",
                dataType: "JSON",
                contentType : "application/json; charset=utf-8",
                data: JSON.stringify({"id":id,"nodeName":nodeName,"nodeType":nodeType,
                                      "regionCode":regionCode,"telCode":telCode,"x":x,"y":y}),
                success : function(data) {
                    if(data.code.code === 0) {
                        alert("添加成功");
                        x_admin_father_reload();
                        x_admin_close();
                    }else{
                        alert(data.code.message);
                    }
                },
                error : function() {
                    alert("error");
                }

            });
        });
    });
</script>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="L_id" class="layui-form-label">
                <span class="x-red">*</span>编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_id" name="id" required="" lay-verify="id"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_nodeName" class="layui-form-label">
                <span class="x-red">*</span>节点名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_nodeName" name="nodeName" required="" lay-verify="nodeName"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_nodeType" class="layui-form-label">
                <span class="x-red">*</span>节点类型
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_nodeType" name="nodeType" required="" lay-verify="nodeType"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_regionCode" class="layui-form-label">
                <span class="x-red">*</span>地区编码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_regionCode" name="regionCode" required="" lay-verify="regionCode"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_telCode" class="layui-form-label">
                <span class="x-red">*</span>电话号码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_telCode" name="telCode" required="" lay-verify="telCode"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_x" class="layui-form-label">
                <span class="x-red">*</span>经度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_x" name="x" required="" lay-verify="x"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_y" class="layui-form-label">
                <span class="x-red">*</span>纬度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_y" name="y" required="" lay-verify="y"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-left: 70px">
            <label class="layui-form-label"></label>
            <button id="add" class="layui-btn" lay-filter="add" lay-submit="">
                增加
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;

        //自定义验证规则
        form.verify({
            id: function(value){
                if(value === '' || value === null){
                    return '编号不能为空';
                }
            }
            ,nodeName: function(value){
                if(value === '' || value === null){
                    return '节点名称不能为空';
                }
            }
            ,nodeType: function(value){
                if(value === '' || value === null){
                    return '节点类型不能为空';
                }
            }
            ,regionCode: function(value){
                if(value === '' || value === null){
                    return '地区编码不能为空';
                }
            }
            ,telCode: function(value){
                if(value === '' || value === null){
                    return '电话号码不能为空';
                }
            }
            ,x: function(value){
                if(value === '' || value === null){
                    return '经度不能为空';
                }
            }
            ,y: function(value){
                if(value === '' || value === null){
                    return '纬度不能为空';
                }
            }
        });
    });
</script>
</body>

</html>